package bcit.nxt.mission;

// TurtleSquare.java
import gin.and.tonic.*;

public class PowerPathFinder implements UltrasonicListener, TouchListener, LightListener
{

    private DragonRobot robot = new DragonRobot();
    int leftLevel = 300;
    int rightLevel = 300;

    PowerPathFinder()
    {
        UltrasonicSensor us = new UltrasonicSensor(SensorPort.S1);
        TouchSensor ts = new TouchSensor(SensorPort.S2);
        LightSensor lsLeft = new LightSensor(SensorPort.S3);
        LightSensor lsRight = new LightSensor(SensorPort.S4);

       
        robot.addPart(us);
        robot.addPart(ts);
        robot.addPart(lsLeft);
        robot.addPart(lsRight);
        // us.addUltrasonicListener(this,30);
        ts.addTouchListener(this);
        lsLeft.addLightListener(this, 250);
        lsRight.addLightListener(this, 250);
        lsLeft.activate(true);
        lsRight.activate(true);

       

        /*robot.setTurtleSpeed(50);
        robot.forward(95);
        robot.backward(34);
        arm.rotateTo(-25, true);
        robot.forward(10);
        robot.backward(72);
         */

         robot.getGear().forward();
    }

    public void bright(SensorPort port, int level)
    {
        if(port==SensorPort.S3)
        {
            robot.getGear().rightArc(0.05);
            return;
            
        }

        if(port==SensorPort.S4)
        {
            
            robot.getGear().leftArc(0.05);
        }

    }

    public void dark(SensorPort port, int level)
    {
        
        robot.getGear().forward();
    }

    public void far(SensorPort port, int level)
    {
        robot.getGear().backward();
    }

    public void near(SensorPort port, int level)
    {
        robot.getGear().right();
    }

    public void pressed(SensorPort port)
    {
        robot.getGear().stop();
        robot.exit();

    }

    public void released(SensorPort port)
    {
        robot.getGear().backward();
    }

    public static void main(String[] args)
    {

        new PowerPathFinder();
    }
}
